home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / FromTheMag / JW FLV MEDIA PLAYER 4.2 / mediaplayer.exe / player.swf / scripts / com / jeroenwijering / parsers / XSPFParser.as < prev   
Text File  |  2008-11-04  |  3KB  |  85 lines

  1. package com.jeroenwijering.parsers
  2. {
  3.    import com.jeroenwijering.utils.Strings;
  4.    
  5.    public class XSPFParser extends ObjectParser
  6.    {
  7.        
  8.       
  9.       public function XSPFParser()
  10.       {
  11.          super();
  12.       }
  13.       
  14.       public static function parse(param1:XML) : Array
  15.       {
  16.          var _loc2_:Array = null;
  17.          var _loc3_:Object = null;
  18.          var _loc4_:XML = null;
  19.          var _loc5_:XML = null;
  20.          _loc2_ = new Array();
  21.          _loc3_ = new Object();
  22.          for each(_loc4_ in param1.children())
  23.          {
  24.             if(_loc4_.localName().toLowerCase() == "tracklist")
  25.             {
  26.                for each(_loc5_ in _loc4_.children())
  27.                {
  28.                   _loc3_ = XSPFParser.parseItem(_loc5_);
  29.                   if(_loc3_["type"] != undefined)
  30.                   {
  31.                      _loc2_.push(_loc3_);
  32.                   }
  33.                   _loc3_ = {};
  34.                }
  35.             }
  36.          }
  37.          return _loc2_;
  38.       }
  39.       
  40.       public static function parseItem(param1:XML) : Object
  41.       {
  42.          var _loc2_:Object = null;
  43.          var _loc3_:XML = null;
  44.          _loc2_ = new Object();
  45.          for each(_loc3_ in param1.children())
  46.          {
  47.             if(!_loc3_.localName())
  48.             {
  49.                break;
  50.             }
  51.             switch(_loc3_.localName().toLowerCase())
  52.             {
  53.                case "location":
  54.                   _loc2_["file"] = _loc3_.text().toString();
  55.                   continue;
  56.                case "title":
  57.                   _loc2_["title"] = _loc3_.text().toString();
  58.                   continue;
  59.                case "annotation":
  60.                   _loc2_["description"] = _loc3_.text().toString();
  61.                   continue;
  62.                case "info":
  63.                   _loc2_["link"] = _loc3_.text().toString();
  64.                   continue;
  65.                case "image":
  66.                   _loc2_["image"] = _loc3_.text().toString();
  67.                   continue;
  68.                case "creator":
  69.                   _loc2_["author"] = _loc3_.text().toString();
  70.                   continue;
  71.                case "duration":
  72.                   _loc2_["duration"] = Strings.seconds(_loc3_.text());
  73.                   continue;
  74.                case "meta":
  75.                   _loc2_[_loc3_.@rel] = _loc3_.text().toString();
  76.                   continue;
  77.                default:
  78.                   continue;
  79.             }
  80.          }
  81.          return ObjectParser.complete(_loc2_);
  82.       }
  83.    }
  84. }
  85.